﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;

namespace SLClient.CustomerControls
{
    public partial class OnlineStatusControl : Page
    {
        public static readonly DependencyProperty OnlineStatusProperty = DependencyProperty.Register("OnlineStatus", typeof(bool), typeof(OnlineStatusControl), new PropertyMetadata(new PropertyChangedCallback(OnOnlineStatusChanged)));

        public OnlineStatusControl()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private static void OnOnlineStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            (d as OnlineStatusControl).SetOnlineStatus((bool)e.NewValue);
        }

        public void SetOnlineStatus(bool onlinestatus)
        {
            if (onlinestatus)
            {
                this.LightGradientStop.Color=Color.FromArgb(0xff, 0, 0xff, 0);
                this.InGradientStop.Color=Colors.Green;
                this.Storyboard_Light.Begin();
            }
            else
            {
                this.LightGradientStop.Color = Colors.White;
                this.InGradientStop.Color = Colors.Gray;
                this.Storyboard_Light.Stop();
            }
        }

        public bool OnlineStatus
        {
            get
            {
                return (bool)base.GetValue(OnlineStatusProperty);
            }
            set
            {
                base.SetValue(OnlineStatusProperty, value);
            }
        }
    }
}
